package com.deviche.taoke.ui.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.deviche.taoke.R;
import com.deviche.taoke.bean.Goods;

import java.util.List;

public class CommonAdapter extends BaseQuickAdapter<Goods,BaseViewHolder> {

    public CommonAdapter(@LayoutRes int layoutResId, @Nullable List<Goods> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Goods item) {
        //可链式调用赋值
        helper.setText(R.id.tv_title, item.getTitle())
                .setText(R.id.tv_content, item.getPrice()+"--"+item.getSales());
        Glide.with(mContext).load(item.getImg()).crossFade().into((ImageView) helper.getView(R.id.iv_img));
        //获取当前条目position
        //int position = helper.getLayoutPosition();
    }
}
